package ru.alex.utils;

import java.io.File;
import java.util.Arrays;

public class FileRenamer {
	private File[] fList;
	private String[] nameList;
	private File dir;
	
	private int id;
	
	public int getId() {return id;}

	final private static String PREF = "PP_";

	String generateValue() {
		String answer = "";
		String template = "00000000";		

		String loc = template.substring(0, template.length()- Long.toString(++id).length());
		answer = PREF + loc + id + ".xml";
		return answer;
	}

	public static void main(String[] args) {
		FileRenamer fr = new FileRenamer();
		String outPath = "D:\\_z\\AISExp2014\\PP\\";		
		
		fr.dir = new File("D:\\_z\\AIS2014\\PP\\"); 
		
		if (fr.dir.isDirectory()) {
			fr.fList = fr.dir.listFiles();

			for (int i = 0; i < fr.fList.length; i++) {
				File itemFile = fr.fList[i];

				System.out.print(itemFile.getName());
				boolean result = itemFile.renameTo(new File(
						outPath + fr.generateValue()));
				System.out.println("  ,i="+i+"  "+result+" ,id="+fr.getId());
				
			}

		}

	}

}
